﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AusProject.OrderComponents;

namespace AusProject
{
    public partial class FormComponentTypeChooser : Form
    {
        public OrderComponentInfo SelectedComponentInfo
        {
            get { return (OrderComponentInfo)lstComponentTypes.SelectedItem; }
        }

        private bool accepted = false;

        public bool Accepted
        {
            get { return accepted; }
        }


        public FormComponentTypeChooser()
        {
            InitializeComponent();
            LoadComponentTypeList();
        }

        private void LoadComponentTypeList()
        {
            lstComponentTypes.Items.Clear();

            OrderComponentInfo ocInfo;

            ocInfo = new OrderComponentInfo(1, "CABINETS", 600, new ComponentColumnInfo[6] { new ComponentColumnInfo(1, "", false, 2), new ComponentColumnInfo(2, "", false, 3), new ComponentColumnInfo(3, "", false, 1.5), new ComponentColumnInfo(4, "", false, 1), new ComponentColumnInfo(5, "", false, 1.5), new ComponentColumnInfo(6, "", false, 1) });
            lstComponentTypes.Items.Add(ocInfo);

            ocInfo = new OrderComponentInfo(2, "BENCHTOPS", 600, new ComponentColumnInfo[6] { new ComponentColumnInfo(7, "", false, 2), new ComponentColumnInfo(8, "", false, 3), new ComponentColumnInfo(9, "", false, 1.5), new ComponentColumnInfo(10, "", false, 1), new ComponentColumnInfo(11, "", false, 1.5), new ComponentColumnInfo(12, "", false, 1) });
            lstComponentTypes.Items.Add(ocInfo);

            ocInfo = new OrderComponentInfo(3, "BOARDS", 600, new ComponentColumnInfo[8] { new ComponentColumnInfo(13, "", false, 2), new ComponentColumnInfo(14, "Qty", true, 1), new ComponentColumnInfo(15, "ID#", true, 1), new ComponentColumnInfo(16, "Type", true, 1), new ComponentColumnInfo(17, "", false, 1.5), new ComponentColumnInfo(18, "", false, 1), new ComponentColumnInfo(19, "", false, 1.5), new ComponentColumnInfo(20, "", false, 1) });
            lstComponentTypes.Items.Add(ocInfo);

            if (lstComponentTypes.Items.Count > 0)
            {
                lstComponentTypes.SelectedIndex = 0;
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            accepted = true;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            accepted = false;
            this.Close();
        }

        private void lstComponentTypes_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int idx = lstComponentTypes.IndexFromPoint(e.Location);
            if (idx >= 0)
            {
                lstComponentTypes.SelectedIndex = idx;
                accepted = true;
                this.Close();
            }
        }


    }
}
